﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QLTinTuc.aspx.cs" Inherits="WebBanThuoc.admin.QLTinTuc" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Quản lý tin tức</title>
    <link rel="shortcut icon" href="../img/admin.ico"></link>
    <script src="../js/jquery-1.7.2.js" type="text/javascript"></script>
        <script src="../js/jquery.keyfilter.js" type="text/javascript"></script>
        <script src="../js/jquery.maskedinput.js" type="text/javascript"></script>
        <script src="../js/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
        <script src="../js/thai.js" type="text/javascript"></script>
        <script src="../js/colResizable-1.3.min.js" type="text/javascript"></script>
        <script src="../ckeditor/ckeditor.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="../style/static.css"/>
        <link rel="stylesheet" type="text/css" href="../style/dangnhap_btn.css"/>
        <link type="text/css" href="../style/flick/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
        <style type="text/css">
            .f_span-74
            {
                width:1100px; 
                float:none;		
                padding: 20px;
            }
            input, textarea {
                -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
                -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
                box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
                -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
                -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
                -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
                -o-transition: border linear 0.2s, box-shadow linear 0.2s;
                transition: border linear 0.2s, box-shadow linear 0.2s;
                line-height: 18px;
                color: #555;
                border: 1px solid #CCC;
                -webkit-border-radius: 3px;
                border-radius: 3px;
                font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                font-size: 15px;
                height: 20px;
                font-weight: normal;
                width: 358px;
            }
            .inputEmail
            {
                height:24px;
            }
            .thai_font
            {
                font-family:"Helvetica Neue", Helvetica, Arial, sans-serif	
            }
            .thai_font_DN
            {
                font-size:30px;
                font-weight:bold;
                padding:10px 0px 30px;		
                color:#0088CC;
                width:820px;
                float:left;
            }
            .thai_font_lable
            {
                font-size:14px;
                font-weight:bold;
                padding-bottom:3px;
                width: 180px;
                margin-top:5px;
            }
            .thai_font_lable_right
            {
                font-size:14px;
                font-weight:bold;
                padding-bottom:3px;
                width: 140px;
                margin-top:5px;
            }
            div{
                float:left;	
            }
        </style>       
        <script language="javascript" type="text/javascript">
                    
            <%if (Session["page_QLTinTuc_dataTinTuc"] == null)
                {%>
                var coDT = false;
            <%}  else{%>
                var coDT = true;
            <%} %>
            
                function CheckRegisterFormEmail(e) {
                    var strEmail = $(e).val();
    
                    regem = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
                    return regem.test(strEmail)
   
                }
                function ModifyProduct(){
                    if($.trim($('#IDTinTuc').val()) == ""){
                        alert("Bạn chưa nhập ID Tin tức.");
                        $('#IDTinTuc').focus();
                        return false;
                    }
                    if(coDT==false){
                        alert("ID Tin tức này không tồn tại trong Cơ sở dữ liệu.");
                        $('#IDTinTuc').focus();
                        return false;
                    }
				    if($.trim($('#TenTinTuc').val()) == ""){
                        alert("Bạn chưa nhập Tên tin tức.");
                        $('#TenTinTuc').focus();
                        return false;
                    }
                }

                function DeleteProduct(){
                    if($.trim($('#IDTinTuc').val()) == ""){
                        alert("Bạn chưa nhập ID Tin tức.");
                        $('#IDTinTuc').focus();
                        return false;
                    }
                    if(coDT==false){
                        alert("ID Tin tức này không tồn tại trong Cơ sở dữ liệu.");
                        $('#IDTinTuc').focus();
                        return false;
                    }
                    
				    if(!confirm("Bạn có muốn xóa Tin tức không ?")){                                               
                        return false;
                    }
                }
			
                function CheckLoginForm_Search(){
                    if($.trim($('#IDTinTuc').val()) == ""){
                        alert("Bạn chưa nhập ID Tin tức.");
                        $('#IDTinTuc').focus();
                        return false;
                    }                
				
                }
			
                function AddProduct(){
                    if($.trim($('#IDTinTuc').val()) != ""){
                        alert("Để thêm Tin tức mới, bạn không được nhập giá trị vào ô ID tin tức.");
                        $('#IDTinTuc').focus();
                        return false;
                    }
				    if($.trim($('#TenTinTuc').val()) == ""){
                        alert("Bạn chưa nhập Tên tin tức.");
                        $('#TenTinTuc').focus();
                        return false;
                    }
                    return true;
				
                }
			
                function searchSP(){
                    var data = $('#IDTinTuc').val();
                    if($.trim(data)==''){
                        alert('Nếu ID Tin tức bỏ trống, tức là bạn đang dùng tính năng thêm mới.');
                        $('#div_spMoi').show(500);
                        $('#IDTinTuc').focus();
                        //return false;
                    } else{
                        $('#frm_TimSP').submit();
                        //return true;
                    }
                }
                $(function(){
  			        
                    setTimeout(function () {
                        $('#IDTinTuc').focus();
                    }, 700);

                    //$('#NgayTao').mask('99/99/9999');
                    //$('#NgaySua').mask('99/99/9999');

                    $("#GiaBan").change(function(){
                        if($(this).val() == ""){
                            $(this).val("0");
                        }
                    });
                    $("#GiaDaGiam").change(function(){
                        if($(this).val() == ""){
                            $(this).val("0");
                        }
                    });
                    $('#KhuyenMai').keypress(function(e){
                        var code = (e.keyCode? e.keyCode:e.which);
                        if(code == 13 || code == 10){
                            return false;	
                        }
                        var rsk = setMaxLength(this,499);
                        if(rsk == false){
                            alert("Không được nhập quá 500 kí tự. Số kí tự hiện giờ là " + this.value.length);
                        }
                        if(code==8 || code==38||code==40||code==37||code==39||code==17||code==18||code==9||code==36||code==35||code==46||code==33||code==34||code==144||code==145){
                            return true;
                        }
                        return rsk;
                    });                                       
			                            
                    
                });
                function setMaxLength(Object, MaxLen)
                {
                    return (Object.value.length <= MaxLen);
                }
                function clearAllInput(){
                    $('#frm_TimSP').find(':input').each(function(){
                        switch(this.type){
                            case 'password':
                            case 'select-multiple':
                            case 'select-one':
                            case 'text':
                            case 'textarea':
                                //if($(this).attr('name')!='MaSanPham'){
                                $(this).val('');
                                //}
                                break;
                            case 'checkbox':
                            case 'radio':
                                this.checked = false;
                                break;
                            case 'file':
                                //this.replaceWith('<input type="file" name="HinhAnh" id="HinhAnh"  style="width:227px" />');
                                $(this).val('');
                                break;
                        }
                    });
                    CKEDITOR.instances["NoiDungSoLuoc"].setData("");
                    CKEDITOR.instances["NoiDung"].setData("");                    
                    coDT = false;
                }            

             <%if (Session["page_QLTinTuc_msgSucessFunc"] != null)
                {%>
                alert("<%=Session["page_QLTinTuc_msgSucessFunc"] %>");
            <%} %>
            
        </script>
</head>
<body>
    <form name="frm_TimSP" id="frm_TimSP" method="post" runat="server" >
        <% WebBanThuoc.DTO.TinTuc objTT = (WebBanThuoc.DTO.TinTuc)Session["page_QLTinTuc_dataTinTuc"]; %>
            <div style="float: none; margin: 20px;" class="f_span-74">
                <div style="width:100%;text-align:center">
                    <div class="thai_font thai_font_DN">QUẢN LÝ TIN TỨC</div>
                </div>
                <div style="width:100%;text-align:center">&nbsp;</div>               
                <div style="width:810px;text-align:left">
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">ID tin tức:</div>                        
                        <input type="text" name="IDTinTuc" id="IDTinTuc" autocomplete="off" class="mask-pint"  maxlength="12"  style="width:100px;float:left" onchange="searchSP()" value="<%=Request.Params["btn_Xoa"] == null ? Request.Params["IDTinTuc"]:""  %>"/>
                        <div style="float:left;color:#666;width:195px; margin-left:15px; font-size:11px; margin-top:0" class="thai_font_lable">Chỉ nhập vào khi sửa hoặc xóa Tin tức.</div>
                    </div>                    
                    <div style="width:100%;text-align:left; margin-bottom:10px;" id="div_spMoi">
                        <div style="width:180px;">&nbsp;</div>                            
                        <div title="ID Tin tức mới tiếp theo nếu bạn tạo Tin tức mới" style="color:Gray; font-size:12px;width: 300px;font-weight: bold;cursor:pointer;"><%=Session["page_QLTinTuc_IDTinTucMoi"]%></div>                            
                    </div>                    
                    <% if (objTT == null && Request.Params["IDTinTuc"] != null && Request.Params["IDTinTuc"] != "" && Request.Params["btn_Xoa"] == null)
                       { %>
                    <div style="width:100%;text-align:left; margin-bottom:10px;">
                        <div style="width:180px;">&nbsp;</div>
                        <div style="color:#F00; font-size:12px;width: 320px;">Không tồn tại ID Tin tức " <%=Request.Params["IDTinTuc"]%> " trong Cơ sở dữ liệu .</div>                            
                    </div>
                    <%} %>
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Tên tin tức:</div>
                        <input type="text" name="TenTinTuc" id="TenTinTuc" autocomplete="off" maxlength="200"  style="width:300px"  value="<%=objTT!=null?objTT.TenTinTuc:"" %>" />
                    </div>
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Danh mục tin tức:</div>
                        <select name="MaDanhMuc" style="width:310px;">
                            <% System.Collections.Generic.List<WebBanThuoc.DTO.DanhMucTinTuc> dataListDM = Session["page_QLTinTuc_dataListDM"] as System.Collections.Generic.List<WebBanThuoc.DTO.DanhMucTinTuc>;
                               for (int i = 0; i < dataListDM.Count; i++)
                               {%>
                                <option value="<%=dataListDM[i].MaDanhMuc %>"  <%=(objTT == null && i == 0) ? "selected='selected'" : ((objTT != null && dataListDM[i].MaDanhMuc == objTT.MaDanhMuc) ? "selected='selected'" : "")%> ><%=dataListDM[i].TenDanhMuc + " - " + dataListDM[i].MaDanhMuc %></option>                                
                            <%} %>
                        </select>
                    </div>

                    
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Nội dung sơ lược:</div>
                        <div style="width:625px;text-align:left;margin-bottom: 8px;">                        
                            <CKEditor:CKEditorControl CssClass="div" Height="100px" ID="NoiDungSoLuoc" 
                                runat="server" ResizeEnabled="false" Toolbar="Source|-|NewPage|Preview|-|Templates
Cut|Copy|Paste|PasteText|PasteFromWord|-|Print|SpellChecker|Scayt
Form|Checkbox|Radio|TextField|Textarea|Select|Button|ImageButton|HiddenField
Undo|Redo|-|Find|Replace|-|SelectAll|RemoveFormat
/
Bold|Italic|Underline|Strike|-|Subscript|Superscript
NumberedList|BulletedList|-|Outdent|Indent|Blockquote|CreateDiv
Link|Unlink|Anchor
Image|Flash|Table|HorizontalRule|Smiley|SpecialChar|PageBreak|Iframe
JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock
BidiLtr|BidiRtl
/
Styles|Format|Font|FontSize
TextColor|BGColor
Maximize|ShowBlocks|-|About" ></CKEditor:CKEditorControl>
                        </div>
                    </div>
                    
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Nội dung chính:</div>
                        <div style="width:625px;text-align:left;margin-bottom: 8px;">                        
                            <CKEditor:CKEditorControl CssClass="div" Height="100px" ID="NoiDung" 
                                runat="server" ResizeEnabled="false" Toolbar="Source|-|NewPage|Preview|-|Templates
Cut|Copy|Paste|PasteText|PasteFromWord|-|Print|SpellChecker|Scayt
Form|Checkbox|Radio|TextField|Textarea|Select|Button|ImageButton|HiddenField
Undo|Redo|-|Find|Replace|-|SelectAll|RemoveFormat
/
Bold|Italic|Underline|Strike|-|Subscript|Superscript
NumberedList|BulletedList|-|Outdent|Indent|Blockquote|CreateDiv
Link|Unlink|Anchor
Image|Flash|Table|HorizontalRule|Smiley|SpecialChar|PageBreak|Iframe
JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock
BidiLtr|BidiRtl
/
Styles|Format|Font|FontSize
TextColor|BGColor
Maximize|ShowBlocks|-|About" FilebrowserImageUploadUrl="/ws/CKEditorUpdateFile.ashx" FilebrowserImageBrowseUrl="/pageSub/CKEditorBrowseImageFile.aspx"></CKEditor:CKEditorControl>
                        </div>
                    </div>
                    
                    <%if (objTT != null)
                      { %>
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Ngày đăng:</div>
                        <input type="text" name="NgayDang" id="NgayDang" style="width:300px"  value="<%=objTT != null ? objTT.NgayDang.ToString("dd/MM/yyyy HH:mm:ss tt") : ""%>" readonly="readonly" tabindex="-1"/>
                    </div>
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Số lượt xem:</div>
                        <input type="text" name="SoLuotXem" id="SoLuotXem"  maxlength="16" class=" mask-pnum"  style="width:300px"  value="<%=objTT!=null?objTT.SoLuotXem.ToString():"" %>" readonly="readonly" tabindex="-1"/>
                    </div>
                    <div style="width:100%;text-align:left">
                        <div style="float:left" class="thai_font_lable">Người đăng:</div>
                        <input type="text" name="SoLuotXem" id="Text1"  maxlength="16" class=" mask-pnum"  style="width:300px"  value="<%=objTT!=null?objTT.UserName:"" %>" readonly="readonly" tabindex="-1"/>
                    </div>
                    <%} %>                    
                </div>

                    
            </div>
                <div style="width:100%;text-align:right; float: right; display: block; position: fixed; z-index: 4000; bottom:0; background-color:#D7FFEB; left:0px">
                    <div style="float:left;padding-top: 0px;"><a href="/admin/home.aspx" ><img alt="" src="../img/home.png" title="Trang Chủ"/></a></div>
                    <div style="float:right;width:110px;">
                        <input type="submit" name="btn_Them" value="Thêm mới" onclick="return AddProduct();" id="btn_Them" class="btn btn-large btn-primary" style="margin:5px"/>            
                    </div>
                    <div style="float:right;width:68px;">
                        <input type="submit" name="btn_Sua" value="Sửa" onclick="return ModifyProduct();" id="btn_Sua" class="btn btn-large btn-primary" style="margin:5px"/>            
                    </div>
                    <div style="float:right;width:68px;">
                        <input type="submit" name="btn_Xoa" value="Xóa" onclick="return DeleteProduct();" id="btn_Xoa" class="btn btn-large btn-primary" style="margin:5px"/>            
                    </div>
                    <div style="float:right;width:125px;">
                        <input type="button" name="btn_Clear" value="Xóa biểu mẫu" onclick="clearAllInput();" id="btn_Clear" class="btn btn-large btn-primary" style="margin:5px"/>            
                    </div>
                </div>
                <div style="width:100%;text-align:left;padding-top:20px;height:80px">
                    &nbsp;
                </div>            

            <%if (objTT != null)
              { %>
                   <script type="text/javascript">
                       $('#div_spMoi').hide();
                   </script>
            <%} %>
            <%Session.Remove("page_QLTinTuc_dataTinTuc");
              Session.Remove("page_QLTinTuc_IDTinTucMoi");
              Session.Remove("page_QLTinTuc_msgSucessFunc"); %>
        </form>
</body>
</html>
